cmake_minimum_required(VERSION 3.5)

# add OSQP library
find_package(osqp REQUIRED)

set(LIBRARY_TARGET_NAME OsqpSolver)

# List of CPP (source) library files.
set(${LIBRARY_TARGET_NAME}_SRC
  Data.cpp
  Settings.cpp
  Solver.cpp)

set(${LIBRARY_TARGET_NAME}_HDR
  include/OsqpSolver/OsqpSolver.h
  include/OsqpSolver/Constants.hpp
  include/OsqpSolver/SparseMatrixHelper.hpp
  include/OsqpSolver/SparseMatrixHelper.tpp
  include/OsqpSolver/Data.hpp
  include/OsqpSolver/Data.tpp
  include/OsqpSolver/Settings.hpp
  include/OsqpSolver/Solver.hpp
  include/OsqpSolver/Solver.tpp)


add_library(${LIBRARY_TARGET_NAME} ${${LIBRARY_TARGET_NAME}_SRC} ${${LIBRARY_TARGET_NAME}_HDR})
target_include_directories(${LIBRARY_TARGET_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
  "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")

target_link_libraries(${LIBRARY_TARGET_NAME} PRIVATE Eigen3::Eigen)
target_link_libraries(${LIBRARY_TARGET_NAME} PUBLIC osqp::osqp)
add_library(OsqpSolver::OsqpSolver ALIAS OsqpSolver)